package cn.miju.database.entity;

import cn.miju.database.model.AlipayMerchantProperties;
import cn.miju.database.model.UnionPayMerchantProperties;
import cn.miju.database.model.WechatpayMerchantProperties;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

/**
 * <pre>
 * 商户
 * </pre>
 *
 * @author zhuming
 * @version 1.0.0
 * @since 2023-03-13 21:53
 */
@Data
@TableName("merchant")
@EqualsAndHashCode(callSuper = true)
public class Merchant extends AutoEntity {
    /**
     * 商户名
     */
    private String merchantName;
    /**
     * 商户类型
     */
    private String merchantType;
    /**
     * 商户配置参数;支付配置参数JSON字符串，详见文档说明
     */
    private String merchantProperties;
    /**
     * 支付结果通知URL
     */
    private String payNotifyUrl;
    /**
     * 退款结果通知URL
     */
    private String refundNotifyUrl;
    /**
     * 平台商户号
     */
    private String platformMerchantNo;
    /**
     * 平台RSA公钥
     */
    private String publicKey;
    /**
     * 平台RSA私钥
     */
    private String privateKey;
    /**
     * 是否返回服务商单号;0：否 1：是，默认0表示返回平台单号
     */
    private boolean toMerchantTradeNo;
    /**
     * 状态
     */
    private String status;

    /**
     * 获取支付宝商户配置信息
     */
    public AlipayMerchantProperties getAlipayMerchantProperties() {
        return StringUtils.isBlank(merchantProperties) ? null : JSONObject.parseObject(merchantProperties, AlipayMerchantProperties.class);
    }

    /**
     * 获取云闪付商户配置信息
     */
    public UnionPayMerchantProperties getUnionPayMerchantProperties() {
        return StringUtils.isBlank(merchantProperties) ? null : JSONObject.parseObject(merchantProperties, UnionPayMerchantProperties.class);
    }

    /**
     * 获取微信商户配置信息
     */
    public WechatpayMerchantProperties getWechatpayMerchantProperties() {
        return StringUtils.isBlank(merchantProperties) ? null : JSONObject.parseObject(merchantProperties, WechatpayMerchantProperties.class);
    }

}
